<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    {$LOAD_STYLE.top|raw}
</head>
<script src="__JS__/clipboard.min.js"></script>
	<body class="pear-container">
		<div class="layui-card">
			<div class="layui-card-body">
				<form class="layui-form layui-form-pane" action="">
					<div class="layui-form-item">
                        
						<div class="layui-form-item layui-inline">
						    <label class="layui-form-label">客户 / 公司</label>
						    <div class="layui-input-inline">
						        <input type="text" name="title" placeholder="称呼 / 公司 / 电话(完整号码) / 旺旺 / QQ" class="layui-input">
						    </div>
						</div>   
						
                        <div class="layui-form-item layui-inline">
                       <button class="pear-btn pear-btn-md pear-btn-primary" lay-submit lay-filter="query">
                           <i class="layui-icon layui-icon-search"></i>
                           查询
                       </button>
                       <button type="reset" class="pear-btn pear-btn-md">
                           <i class="layui-icon layui-icon-refresh"></i>
                           重置
                       </button>
                       </div>
                    </div>
				</form>
			</div>
		</div>
		<div class="layui-card">
			<div class="layui-card-body">
				<table id="dataTable" lay-filter="dataTable"></table>
			</div>
		</div>

		<script type="text/html" id="toolbar">
			<button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add">
		        <i class="layui-icon layui-icon-add-1"></i>
		        新增
			</button>
			<button class="pear-btn pear-btn-danger pear-btn-md" lay-event="batchRemove">
		        <i class="layui-icon layui-icon-delete"></i>
		        删除
		    </button>
            <button class="pear-btn pear-btn-md" lay-event="recycle">
		        <i class="layui-icon layui-icon-delete"></i>
		        回收站
		    </button>
			
			<button class="pear-btn pear-btn-ext1 pear-btn-md toolbar-btn-left" lay-event="pop" url="{:U('customer.grade/add')}" poptitle="新增客户等级">
			    <i class="layui-icon layui-icon-add-1"></i>
			    新增客户等级
			</button>
			<button class="pear-btn pear-btn-ext1 pear-btn-md" lay-event="jump" url="{:U('customer.grade/index')}" poptitle="客户管理">
			    <i class="layui-icon layui-icon-table"></i>
			    客户管理
			</button>
		</script>

        
	   <script type="text/html" id="status">
		   <input type="checkbox" name="status" value="{{d.id}}" lay-skin="switch" lay-text="启用|禁用" lay-filter="status" {{# if(d.status==1){ }} checked {{# } }}>
	   </script>
	   
	   <script type="text/html" id="wangid">
	   {{# if(d.wangid!=''){ }}
	   <a target="_blank" href="http://www.taobao.com/webww/ww.php?ver=3&amp;touid={{ d.wangid }}&amp;siteid=cntaobao&amp;status=2&amp;charset=utf-8"><img border="0" src="http://amos.alicdn.com/realonline.aw?v=2&amp;uid={{ d.wangid }}&amp;site=cntaobao&amp;s=2&amp;charset=utf-8" alt="点击这里给我发消息"></a>
	   {{# } }}
	   </script>
	   
	   <script type="text/html" id="customer">
		   <div copy="{{d.name}},{{d.phone}},{{d.address2}}">
			<a href="javascript:;" title="点击复制客户地址信息">{{ d.name }}</a>
		   </div>
	   </script>

		<script type="text/html" id="options">
		{if isMobile()}
		<div class="layui-row">
			<div class="layui-col-xs10">
			  【{{ d.name }}】
			</div>
			<div class="layui-col-xs2 layui-right">
			  {{# if(d.status==1){ }}
			  <span class="layui-tag pear-btn-green">启用</span>
			  {{# }else{ }}
			  <span class="layui-tag pear-btn-grey">禁用</span>
			  {{# } }}
			</div>
		</div>
		<div class="layui-row">
			<div class="layui-col-xs12">
				{{ d.province }} {{ d.company }}
			</div>
		</div>
		{/if}
		<div class="layui-options">
		<button class="pear-btn pear-btn-ext1 pear-btn-sm" lay-event="pop" url="{:U('customer.sample/index')}/cusid/{{ d.id }}" poptitle="【{{ d.name }}】拿样记录" popsize="0.8"><i class="layui-icon layui-icon-read"></i></button>
		<button class="pear-btn pear-btn-cyan pear-btn-sm" lay-event="pop" url="{:U('deal.main/history')}/cusid/{{ d.id }}" poptitle="【{{ d.name }}】历史订单" popsize="0.98"><i class="layui-icon layui-icon-search"></i></button>
			<button class="pear-btn pear-btn-primary pear-btn-sm" lay-event="edit"><i class="layui-icon layui-icon-edit"></i></button>
		    <button class="pear-btn pear-btn-danger pear-btn-sm" lay-event="remove"><i class="layui-icon layui-icon-delete"></i></button>
		</div>
		</script>
        <script>
        layui.use(['jquery','common','mycomm'], function() {
            let $ = layui.jquery;
			let common = layui.common;
			let mycomm = layui.mycomm;
            let MODULE_PATH = "{$MODULE_PATH}";
            
			{if isMobile()}
			let cols = [
			    [
					{
						title: '操作',
						toolbar: '#options',
						unresize: true,
						align: 'left',
			        }
			    ]
			];
			{else/}
            let cols = [
                [{
                        type: 'checkbox'
                    },{
                       field: "create_time",
                       title: "添加时间",
					   width: 160,
                       unresize: "true",
                       align: "center",
                   }, {
                       field: "province",
                       title: "省份",
					   width: 100,
                       unresize: "true",
                       align: "center"
                   }, {
                       field: "name",
                       title: "客户昵称",
					   width: 120,
					   templet: "#customer",
                       unresize: "true",
                       align: "center"
                   }, {
                       field: "company",
                       title: "公司名",
					   width: 250,
                       unresize: "true",
                       align: "left"
                   }, {
                       field: "phone",
                       title: "电话号码",
					   width: 150,
                       unresize: "true",
					   hide: "true",
                       align: "center",
                   }, {
                       field: "wangid",
                       title: "旺旺ID",
					   width: 80,
					   templet: "#wangid",
                       unresize: "true",
                       align: "center"
                   }, {
                       field: "dealtotal",
                       title: "累计成交金额",
					   width: 100,
					   sort: true,
                       unresize: "true",
                       align: "center"
                   }, {
                       field: "dealtime",
                       title: "最近成交时间",
					   width: 120,
                       unresize: "true",
                       align: "center"
                   }, {
                       field: "grade",
                       title: "客户等级",
					   width: 100,
                       unresize: "true",
                       align: "center"
                   }, {
                       field: "status",
                       title: "状态",
					   width: 100,
                       unresize: "true",
                       align: "center",
                       templet:"#status"
                   }, {
                        title: '操作',
                        toolbar: '#options',
                        unresize: true,
						width: 200,
						fixed: "right",
                        align: 'center',
                    }
                ]
            ]
			{/if}
			
			mycomm.tableInit('{$controller_title}',MODULE_PATH,cols);

        })
    </script>
	{$LOAD_STYLE.bottom|raw}
	</body>
</html>
